import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import pinia from '@/store'
import 'element-plus/dist/index.css'
import mavonEditor from 'mavon-editor'
import 'mavon-editor/dist/css/index.css'
import baseIcon from '@/components/base-icon/Index.vue'
import baseTitle from '@/components/base-title/Index.vue'
import 'default-passive-events'
const app = createApp(App)
app.use(pinia)
app.use(router)
app.use(mavonEditor)
app.component('base-icon', baseIcon)
app.component('base-title', baseTitle)
app.mount('#app')

// 自定义权限指令
// const permiss = usePermissStore()
// app.directive('permiss', {
//   mounted(el, binding) {
//     if (!permiss.key.includes(String(binding.value))) {
//       el['hidden'] = true
//     }
//   },
// })

// 自定义节流指令 防止多次重复点击 多次请求数据
app.directive('preventReClick', {
  mounted(el, binding) {
    el.addEventListener('click', () => {
      if (!el.disabled) {
        el.disabled = true
        setTimeout(() => {
          el.disabled = false
        }, binding.value || 1500)
      }
    })
  },
})
